package com.kasax.test.bc.viewmodel

import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.kasax.hilog.Logger
import kotlinx.coroutines.launch

class TestViewModel : ViewModel() {
    /**
     * 图片:可变
     */
    private var _imgs = MutableLiveData<List<String>>()

    /**
     * 不可变，用于观察
     */
    val datas: LiveData<List<String>> = _imgs


    fun fetchData() {
        Logger.log("fetchData")
        // 如何在这里使用协程
        viewModelScope.launch {
            Logger.log("fetchData filldata")
            ""
            _imgs.value = listOf(
                "https://gips3.baidu.com/it/u=71196357,2063808844&fm=3042&app=3042&f=JPEG&wm=1,baiduai3,0,0,13," + "9&wmo=5,5&w=512&h=512",
                "https://gips3.baidu.com/it/u=71196357,2063808844&fm=3042&app=3042&f=JPEG&wm=1,baiduai3,0,0,13," + "9&wmo=5,5&w=512&h=512",
                "https://gips3.baidu.com/it/u=71196357,2063808844&fm=3042&app=3042&f=JPEG&wm=1,baiduai3,0,0,13," + "9&wmo=5,5&w=512&h=512",
                "https://gips3.baidu.com/it/u=71196357,2063808844&fm=3042&app=3042&f=JPEG&wm=1,baiduai3,0,0,13," + "9&wmo=5,5&w=512&h=512",
                "https://gips3.baidu.com/it/u=71196357,2063808844&fm=3042&app=3042&f=JPEG&wm=1,baiduai3,0,0,13," + "9&wmo=5,5&w=512&h=512",
                "https://gips3.baidu.com/it/u=71196357,2063808844&fm=3042&app=3042&f=JPEG&wm=1,baiduai3,0,0,13," + "9&wmo=5,5&w=512&h=512",
                "https://gips3.baidu.com/it/u=71196357,2063808844&fm=3042&app=3042&f=JPEG&wm=1,baiduai3,0,0,13," + "9&wmo=5,5&w=512&h=512",
                "https://gips3.baidu.com/it/u=71196357,2063808844&fm=3042&app=3042&f=JPEG&wm=1,baiduai3,0,0,13," + "9&wmo=5,5&w=512&h=512",
                "https://gips3.baidu.com/it/u=71196357,2063808844&fm=3042&app=3042&f=JPEG&wm=1,baiduai3,0,0,13," + "9&wmo=5,5&w=512&h=512",
                "https://gips3.baidu.com/it/u=71196357,2063808844&fm=3042&app=3042&f=JPEG&wm=1,baiduai3,0,0,13," + "9&wmo=5,5&w=512&h=512",
                "https://gips3.baidu.com/it/u=71196357,2063808844&fm=3042&app=3042&f=JPEG&wm=1,baiduai3,0,0,13," + "9&wmo=5,5&w=512&h=512",


                )
        }
    }


}